package com.sjh.lib_app.utils

import android.view.View
import com.sjh.lib_app.UserConfig
import com.sjh.lib_app.event.SignOutEvent
import com.sjh.lib_app.router.route
import org.greenrobot.eventbus.EventBus

/**
 *  项目里面一些统一的UI处理逻辑
 * @author : SunJH
 * @data : 2020/12/3
 */

/**
 * 显示或者隐藏联系客服，默认都不显示
 * @param isShowPhone true 显示
 * @param isShowqq true 显示
 */
fun showOrHideService(isShowqq: Boolean, isShowPhone: Boolean, aboutQQView: List<View>, aboutPhoneView: List<View>) {
    if (isShowqq) {
        aboutQQView.forEach { it.visibility = View.VISIBLE }
    } else {
        aboutQQView.forEach { it.visibility = View.GONE }
    }
    if (isShowPhone) {
        aboutPhoneView.forEach { it.visibility = View.VISIBLE }
    } else {
        aboutPhoneView.forEach { it.visibility = View.GONE }
    }
}

/**
 * 退出登录
 */
fun logout() {
    EventBus.getDefault().post(SignOutEvent())
    UserConfig.clearData()
    route("/login/login", "loginType" to "1")
}